﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using A911CareerKit.Common;

namespace A911CareerKit.Favorites.Model
{
    public class Favorites : LoadSaveSupport<Favorites>, IEnumerable<Favorite>
    {
        public List<Favorite> Items { get; private set; }

        internal Favorites()
        {
            Items = new List<Favorite>();
        }

        /// <summary>
        /// Creates new list of favorites
        /// </summary>
        public static Favorites New()
        {
            return new Favorites();
        }

        #region Load/Save


        /// <summary>
        /// Save to default location (see properties)
        /// </summary>
        public void Save()
        {
            Save(Properties.Settings.Default.DefaultFavoritesFile);
        }

        /// <summary>
        /// Load from default location (see properties)
        /// </summary>
        /// <returns></returns>
        public static Favorites Load()
        {
            return Load(Properties.Settings.Default.DefaultFavoritesFile);
        }

        #endregion

        #region IEnumerable Members

        public IEnumerator<Favorite> GetEnumerator()
        {
            return Items.GetEnumerator();
        }

        public void Add(object item)
        {
            Items.Add((Favorite)item);
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return Items.GetEnumerator();
        }

        #endregion
    }
}
